class Solution {
public:
    int dp[10010];
    int MLS(vector<int>& arr) {
        sort(arr.begin(), arr.end());
        int ans = 0;
        dp[0] = 1;
        for(int i = 1; i < arr.size(); i++)
        {
            if(arr[i - 1] + 1 == arr[i]) dp[i] = dp[i - 1] + 1;
            else if(arr[i - 1] == arr[i]) dp[i] = dp[i - 1];
            else dp[i] = 1;
            ans = max(ans, dp[i]);
        }
        return ans;
    }
};
